Montage is a general astronomical image toolkit with facilities for reprojection, background matching, coaddition and visualization. It can be used as a set of command-line tools (Linux, OS X and Windows), C library calls (Linux and OS X) and as Python binary extension modules.
Montage source code can be downloaded from GitHub ( https://github.com/Caltech-IPAC/Montage ). The Python package can be installed from PyPI ("pip install MontagePy"). See http://montage.ipac.caltech.edu/ for more information.
Sometimes you may want to find the image in a set that "best" overlaps a specific location on the sky. Best in this case is defined as the image where the location of interest is farthest from the nearest edge. In other words, if you were to do a cutout around your location, this is the image that would give the largest area without hitting an edge.
from MontagePy.main import mBestImage, mViewer
help(mBestImage)
In this example, we have a set of image used to make a mosaic around M17 and we wish to find the image in the set that best covers M17 itself (RA = 275.19629, Dec = -16.17153).
rtn = mBestImage('M17/rimages.tbl', 275.19629, -16.17153)
print(rtn)
Here is the full mosaic, with the input images outlines shown in blue and the location of M17 shown as a black circle:
from IPython.display import Image
rtn = mViewer('-color blue -imginfo M17/rimages.tbl \
-color yellow -symbol 6.0 circle \
-mark 275.19629 -16.17153 \
-ct 1 -gray M17/mosaic.fits \
-2s max gaussian-log -out work/M17/bestimg.png',
'', mode=2)
Image(filename='work/M17/bestimg.png')